package com.gaofeng.day10;

import java.util.Random;
import java.util.Scanner;

/**
 * @author gaofeng
 * @date 2024-12-22 - 9:21
 */
public class demo09 {
    public static void main(String[] args) {
        Random random = new Random();
        int number = random.nextInt(100) + 1;
        int count = 0;
        Scanner scanner = new Scanner(System.in);
        while (true){
            System.out.println("请输入要猜的数字");
            int gessNumber = scanner.nextInt();
            count++;
            if(count >= 3){
                System.out.println("游戏结束");
                break;
            }

            if(gessNumber >  number){
                System.out.println("大了");
            }else if(gessNumber < number){
                System.out.println("小了");
            }else{
                System.out.println("回答正确"+number);
                scanner.close();
                break;
            }
        }

    }
}
